#include <iostream>
#include "Matrix.h"
using namespace std;


Matrix::Matrix()
{

}

Matrix::Matrix(int **values)
{
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			arr[i][j] = values[i][j];
}

void Matrix::display()
{
	for(int i=0; i<rows; i++)
	{
		for(int j=0; j<cols; j++)
			cout<<arr[i][j]<<"\t";
		cout<<endl;
	}
}

Matrix* Matrix::add(Matrix& mat)
{
	Matrix *res = new Matrix();
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			res->arr[i][j] = this->arr[i][j] + mat.arr[i][j];
	return res;
}

Matrix* Matrix::sub(Matrix& mat)
{
	Matrix *res = new Matrix();
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			res->arr[i][j] = this->arr[i][j] - mat.arr[i][j];
	return res;
}

Matrix* Matrix::mul(Matrix& mat)
{
	Matrix *res = new Matrix();
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
		{
			res->arr[i][j] = 0;
			for(int k = 0; k<cols; k++)
				res->arr[i][j] += this->arr[i][k]*mat.arr[k][j];
		}
	return res;
}